# -*- coding: utf-8 -*-

from odoo_contrib.exceptions import BaseOdooException


class WechatAuthException(BaseOdooException):
    # category
    # auth: 10
    category = 'wechat-auth'

    # sub category:
    #   - wechat.login 10
    #   - wechat.auth 20

    co_msg_mapping = {
        101001: {
            'message': 'code required',
            'http_code': 400,
            'sub_category': 'wechat.login',
        },
        101002: {
            'message': 'No openid found in session_info returned from wechat',
            'http_code': 400,
            'sub_category': 'wechat.login',
        },
        101003: {
            'message': 'Retrieving session_info from wechat(miniapp) error',
            'http_code': 400,
            'sub_category': 'wechat.login',
        },
        101004: {
            'message': 'Retrieving session_info from wechat(mpapp) error',
            'http_code': 400,
            'sub_category': 'wechat.login',
        },
        101005: {
            'message': 'Unknown wechat app type',
            'http_code': 400,
            'sub_category': 'wechat.login',
        },
        102001: {
            'message': 'Missing token',
            'http_code': 400,
            'sub_category': 'wechat.auth',
        },
        102002: {
            'message': 'Token format error',
            'http_code': 400,
            'sub_category': 'wechat.auth',
        },
        102003: {
            'message': 'Token expired',
            'http_code': 400,
            'sub_category': 'wechat.auth',
        },
        102004: {
            'message': 'Token corrupted',
            'http_code': 400,
            'sub_category': 'wechat.auth',
        },
        102005: {
            'message': 'Missing uid in deserialized data',
            'http_code': 400,
            'sub_category': 'wechat.auth',
        },
        102006: {
            'message': 'Wechat user not found by id',
            'http_code': 404,
            'sub_category': 'wechat.auth',
        },
    }
